<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

/**
 * Init Model
 *
 */


class Term_model extends CI_Model {

	function __construct(){
		parent::__construct();
	}


	function getTermValue($profileID=0,$term='',$limit=1){

		$sql = "select value from term where post_id = $profileID and term ='$term' limit $limit ";
		//print $sql; die();
		$query = $this->db->query($sql);
		if($query->num_rows() > 0){
			$result = $query->result();
			return $result[0]->value;
		}else{
			return FALSE;
		}
	}

	function getTermCategory($postID = 0,$term = ''){

		$sql ="Select value from term where post_id = $postID and term = '$term' order by (id) ASC";

		$query = $this->db->query($sql);
		if($query->num_rows() > 0){
			$result = $query->result();
			return $result;
		}else{
			return FALSE;
		}

	}
	
	function getKeyword($post_id = 0,$value = 0){
		$sql = "select * from term where post_id=$post_id and value=$value limit 1";
		$query = $this->db->query($sql);
		if($query->num_rows()!=0){
			return $query->row()->value;
		}else{
			return 0;
		}
	
		 
		 
	}


}
